package com.jay.compass.utils;

/**
 * Timer, used for count down purposes
 * 
 * @author Administrator
 */
public class BTimer extends Thread {
	private final int time;
	public int time_left;
	static private BTimer mTimer;

	public BTimer(int t) {
		time = t;
	}

	static public BTimer getInstance() {
		return mTimer;
	}

	public static void setTimer(BTimer timer) {
		mTimer = timer;
	}

	public void update(int i) {
		time_left = i;
	}

	public void run() {
		time_left = time;
		try {
			while (time_left > 0) {
				BTimer.sleep(1000);
				time_left--;
			}
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		mTimer = null;
		return;
	}

	public int gettimeleft() {
		return time_left;
	}
}